package com.cnpinxi.service;

import com.cnpinxi.dao.DistributionRateMapper;
import com.cnpinxi.domain.DistributionRate;
import com.cnpinxi.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2017-12-21.
 */
@Service
public class DistributionRateServiceImpl implements com.cnpinxi.service.DistributionRateService {
    @Autowired
    DistributionRateMapper distributionRateMapper;
    @Override
    public void modifyDistributionRate(DistributionRate distributionRate) {
        if(distributionRate.getTid()==null){
            distributionRateMapper.insert(distributionRate);
        }else{
            distributionRateMapper.updateByPrimaryKey(distributionRate);
        }

    }

    @Override
    public void deleteDistributionRate(DistributionRate distributionRate) {
        distributionRateMapper.deleteByPrimaryKey(distributionRate.getTid());

    }

    @Override
    public DistributionRate getDistributionRate(Map<String, String> map) {
        return distributionRateMapper.selectByPrimaryKey(map);
    }

    @Override
    public List<DistributionRate> getDistributionRateList(Map<String, String> map) {
        return distributionRateMapper.getDistributionRateList(map);
    }

    @Override
    public DistributionRate getDistributionRateBysell(Integer sellAmount) {
        return distributionRateMapper.getDistributionRateBysell(sellAmount);
    }
}
